package com.hdyg.sixg.activity.home;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.allen.library.SuperTextView;
import com.hdyg.sixg.R;
import com.hdyg.sixg.activity.common.BaseActivity;
import com.hdyg.sixg.mvp.base.SpMsg;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import butterknife.BindView;

/**
 * @author CZB
 * @describe 流通钱包详情
 * @time 2019/4/8 11:23
 */
// TODO: 2019/4/20 流通钱包详情
public class CurrentMoneyDetailActivity extends BaseActivity {

    public static final int RECHARGE_DETAIL_TYPE = 0x00001; //充值详情
    public static final int TRANSFER_DETAIL_TYPE = 0x00002; //转账详情
    public static final int HOST_DETAIL_TYPE = 0x00003;     //托管详情
    public static final int EXCHANGE_DETAIL_TYPE = 0x00004; //兑换详情

    @BindView(R.id.ll_top_left)
    LinearLayout llTopLeft;
    @BindView(R.id.tvTopTitle)
    TextView tvTopTitle;
    @BindView(R.id.sv_type)
    SuperTextView svType;
    @BindView(R.id.sv_number)
    SuperTextView svNumber;
    @BindView(R.id.sv_pack)
    SuperTextView svPack;
    @BindView(R.id.sv_time)
    SuperTextView svTime;
    @BindView(R.id.rv_image)
    RecyclerView rvImage;
    @BindView(R.id.srl_refresh)
    SmartRefreshLayout srlRefresh;
    @BindView(R.id.sv_fee)
    SuperTextView svFee;
    @BindView(R.id.sv_pack_2)
    SuperTextView svPack2;
    @BindView(R.id.sv_get_number)
    SuperTextView svGetNumber;
    @BindView(R.id.sv_exchange_income_pack)
    SuperTextView svExchangeIncomePack;
    @BindView(R.id.ll_recharge)
    LinearLayout llRecharge;

    private int detail_type;//详情类型

    @Override
    protected int getLayoutId() {
        return R.layout.activity_current_money_detail;
    }

    @Override
    protected void initView() {
        detail_type = getIntent().getIntExtra(SpMsg.INTENT_CODE, RECHARGE_DETAIL_TYPE);//默认充值详情
        if (detail_type == RECHARGE_DETAIL_TYPE) {
            //充值详情
            svFee.setVisibility(View.GONE);
            svPack2.setVisibility(View.GONE);
            svGetNumber.setVisibility(View.GONE);
            svExchangeIncomePack.setVisibility(View.GONE);
        } else if (detail_type == TRANSFER_DETAIL_TYPE){
            //转账详情
            svNumber.setLeftString(getResources().getString(R.string.current_detail_transfer_number));
            svPack.setLeftTopString(getResources().getString(R.string.current_pay_pack));
            llRecharge.setVisibility(View.GONE);
            svGetNumber.setVisibility(View.GONE);
            svExchangeIncomePack.setVisibility(View.GONE);
        }else if (detail_type == HOST_DETAIL_TYPE){
            //托管
            llRecharge.setVisibility(View.GONE);
            svFee.setVisibility(View.GONE);
            svPack.setVisibility(View.GONE);
            svGetNumber.setVisibility(View.GONE);
            svExchangeIncomePack.setVisibility(View.GONE);
            svNumber.setLeftString(getResources().getString(R.string.current_detail_reward_number));
        }else if (detail_type == EXCHANGE_DETAIL_TYPE){
            //兑换
            llRecharge.setVisibility(View.GONE);
            svPack.setVisibility(View.GONE);
            svPack2.setVisibility(View.GONE);
            svGetNumber.setVisibility(View.VISIBLE);
            svExchangeIncomePack.setVisibility(View.VISIBLE);
            svNumber.setLeftString(getResources().getString(R.string.current_detail_exchange_number));
        }
        onClickListener();
        tvTopTitle.setText(R.string.current_detail_title);
        rvImage.setLayoutManager(new GridLayoutManager(mContext,4));
    }

    private void onClickListener() {
        srlRefresh.setOnRefreshListener(refreshLayout -> {
            srlRefresh.finishRefresh(2000);//传入false表示刷新失败
        });
        llTopLeft.setOnClickListener(v -> finish());

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void createPresenter() {

    }

}
